<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1.0" name="viewport">


    <title>商品详情</title>

    <link href="../../resource/css/bootstrap.min.css?v=3.3.5" rel="stylesheet"
          th:href="@{/resource/css/bootstrap.min.css?v=3.3.5}"/>
    <link href="../../resource/hotui/css/font-awesome.min.css" rel="stylesheet"
          th:href="@{/resource/hotui/css/font-awesome.min.css}">
    <!-- Morris -->
    <link href="../../resource/hotui/css/plugins/morris/morris-0.4.3.min.css"
          rel="stylesheet" th:href="@{/resource/hotui/css/plugins/morris/morris-0.4.3.min.css}">
    <link href="../../resource/css/animate.min.css" rel="stylesheet" th:href="@{/resource/css/animate.min.css}"/>
    <link href="../../resource/hotui/css/style.min-1.0.8.css" rel="stylesheet"
          th:href="@{/resource/hotui/css/style.min-1.0.8.css}">
    <link href="../../resource/hotui/css/hotui.style.override.css"
          rel="stylesheet" th:href="@{/resource/hotui/css/hotui.style.override.css}"/>
</head>

<body class="gray-bg">
<div class="animated fadeInRight"
     style="padding:0 6px;position:fixed;width:100%;top: 0;z-index:101;">
    <div class="col-lg-12">
        <div class="ibox float-e-margins" style="margin-bottom:0;">
            <div class="ibox-title" style="padding: 14px 15px 11px;">
                <div class="form-inline">
                    <div class="form-group m-r-sm">
                        <label style="font-size: 17px; margin-top: 5px;">
                            <span th:text="${model.data.title}">数农旗舰店</span>

                            <span style="font-size: 13px;">
                                                <span class="color-primary" th:if="${model.auditStatus.code==1}"
                                                >审核通过</span>
                                                <span class="color-warning"
                                                      th:if="${model.auditStatus.code==0}"
                                                      th:text="${model.auditStatus.desc}">待审核</span>
                                                <span class="color-danger" th:if="${model.auditStatus.code==2}"
                                                      th:text="${model.auditStatus.desc}">审核失败</span>
                            </span>
                        </label>
                    </div>
                    <button class="btn btn-success btn-sm" th:if="${model.auditStatus.code==0}"
                            th:onclick="handler.modifyAudit([[${model.merchantId}]])"
                            type="button">
                        审核
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="wrapper wrapper-content animated fadeInRight tooltip-demo" style="margin-top: 59px;" th:object="${model}">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="tabs-container">
                    <input id="merchantId" th:value="*{merchantId}" type="hidden"/>

                    <ul class="nav nav-tabs">
                        <li class="active"><a href="order_detail.html">基本信息</a></li>
                    </ul>

                    <div class="ibox-title"
                         style="vertical-align: bottom;height: 100%;padding-left: 30px;border-left: 1px solid #e9ebed;border-right:1px solid #e9ebed;">
                        <h5 style="font-size: 18px;">
                            <img alt="" onerror="this.src='../../resource/img/d_head.jpeg'"
                                 src="../../resource/img/p2.jpg"
                                 style="width:100px;height:100px;"
                                 th:onerror="|this.src='@{/resource/img/d_head.jpeg}'|" th:src="*{data.avatar}">
                        </h5>
                        <div style="margin-left: 120px;width: 50%;margin-top: 6px;">
                            <h3 th:text="*{data.title}">数农旗舰店</h3>
                            <p style="width: 373px;height: 31px;" th:text="*{data.description}">
                            </p>
                            <p>创建时间：<span th:text="*{createTime}"></span></p>
                        </div>
                    </div>

                    <ul class="nav nav-tabs" style="margin-top: 20px;">
                        <li class="active"><a th:href="@{/merchant/detail(id=${model.merchantId})}"
                                              href="order_detail.html">基本信息</a>
                        </li>
                        <li><a th:href="@{/merchant/detail/advanceLog/2(userId=${model.merchantId})}"
                               href="order_detail.html">货款明细</a></li>
                        <li><a th:href="@{/merchant/detail/advanceLog/3(userId=${model.merchantId})}"
                               href="order_detail.html">待入账货款明细</a></li>
                        <li><a th:href="@{/merchant/detail/depositLogs(merchantId=${model.merchantId})}"
                               href="order_detail.html">保证金明细</a>
                        </li>
                    </ul>

                    <div class="tab-content">
                        <div class="tab-pane active">
                            <div class="panel-body">


                                <div class="row">
                                    <div class="col-sm-6">
                                        <div class="ibox float-e-margins">
                                            <div class="ibox-content p-xxs no-borders">
                                                <label>店铺信息：</label>
                                                <p style="height: 5px;"></p>
                                                <table class="table table-bordered order-detail-table">
                                                    <tbody>
                                                    <tr>
                                                        <th>微信号：</th>
                                                        <td>
                                                            <span th:text="*{data.wechatAccount}">20170110095434456651</span>
                                                        </td>
                                                        <th>联系方式：</th>
                                                        <td>
                                                            <span th:text="*{data.contactWay}">176998989889</span>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>主体信息：</th>
                                                        <td>
                                                            <span th:text="*{information.entityType}=='enterprise'?'企业':'个人'">企业</span>
                                                        </td>
                                                        <th>主营类目：</th>
                                                        <td>
                                                            <span th:text="*{data.mainCategory.catName}"></span>
                                                        </td>
                                                    </tr>
                                                    <tr th:if="*{information.entityType=='enterprise'}">
                                                        <th>企业名称：</th>
                                                        <td colspan="3">
                                                            <span th:text="*{information.enterpriseName}"></span>
                                                        </td>
                                                    </tr>
                                                    <tr th:if="*{information.entityType=='person'}">
                                                        <th>姓名：</th>
                                                        <td>
                                                            <span th:text="*{information.personName}">--</span>
                                                        </td>
                                                        <th>身份证号：</th>
                                                        <td>
                                                            <span th:text="*{information.personId}">--</span>
                                                        </td>
                                                    </tr>
                                                    <tr th:if="*{information.entityType=='person'}">
                                                        <th>身份证正面：</th>
                                                        <td>
                                                            <img alt="" onclick="previewImage(this)"
                                                                 height="50"
                                                                 th:src="*{information.personIdFace}"
                                                                 width="100">
                                                        </td>
                                                        <th>身份证反面：</th>
                                                        <td>
                                                            <img alt="" onclick="previewImage(this)"
                                                                 height="50"
                                                                 th:src="*{information.personIdEmblem}"
                                                                 width="100">
                                                        </td>
                                                    </tr>


                                                    <tr th:if="*{information.entityType=='enterprise'}">
                                                        <th>法人姓名：</th>
                                                        <td class="color-warning"
                                                            style="font-size: 14px; font-weight: bold;">
                                                            <span th:text="*{information.enterpriseLegalPersonName}">100</span>
                                                        </td>
                                                        <th>法人身份证号：</th>
                                                        <td>
                                                            <span
                                                                    th:text="*{information.enterpriseLegalPersonId}">0</span>
                                                        </td>
                                                    </tr>

                                                    <tr th:if="*{information.entityType=='enterprise'}">
                                                        <th>身份证正面：</th>
                                                        <td>
                                                            <img alt="" onclick="previewImage(this)"
                                                                 height="50"
                                                                 th:src="*{information.enterpriseLegalPersonIdFace}"
                                                                 width="100">
                                                        </td>
                                                        <th>身份证反面：</th>
                                                        <td>
                                                            <img alt="" onclick="previewImage(this)"
                                                                 height="50"
                                                                 th:src="*{information.enterpriseLegalPersonIdEmblem}"
                                                                 width="100">
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>营业执照：</th>
                                                        <td>
                                                            <img alt="" onclick="previewImage(this)"
                                                                 height="50"
                                                                 th:src="*{information.enterpriseLicenseCopy}"
                                                                 width="100">
                                                        </td>
                                                        <th>非遗传承人证书：</th>
                                                        <td>
                                                            <img alt="" onclick="previewImage(this)"
                                                                 height="50"
                                                                 th:src="*{information.certificateOfIntangibleCultural}"
                                                                 width="100">
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>描述：</th>
                                                        <td colspan="3" th:text="*{data.description}"></td>
                                                    </tr>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-6">
                                        <div class="ibox float-e-margins">
                                            <div class="ibox-content p-xxs no-borders">
                                                <label>退货信息：</label>
                                                <p style="height: 5px;"></p>
                                                <table class="table table-bordered order-detail-table">
                                                    <tbody>
                                                    <tr>
                                                        <th>姓名：</th>
                                                        <td colspan="3"
                                                            th:text="*{data.returnedPurchase.userName}"></td>
                                                    </tr>
                                                    <tr>
                                                        <th>手机：</th>
                                                        <td colspan="3"
                                                            th:text="*{data.returnedPurchase.telNumber}"></td>
                                                    </tr>
                                                    <tr>
                                                        <th>收货地址：</th>
                                                        <td colspan="3"
                                                            th:text="*{data.returnedPurchase.fullAddress()}"></td>
                                                    </tr>
                                                    <tr>
                                                        <td colspan="2">
                                                            <input id="hdShipUserName"
                                                                   th:value="${model.data.returnedPurchase!=null ? model.data.returnedPurchase.userName:'--'}"
                                                                   type="hidden">
                                                            <input id="hdShipTelNumber"
                                                                   th:value="${model.data.returnedPurchase!=null ? model.data.returnedPurchase.telNumber:'--'}"
                                                                   type="hidden">
                                                            <input id="hdProvinceCode"
                                                                   th:value="${model.data.returnedPurchase!=null ? model.data.returnedPurchase.provinceCode:''}"
                                                                   type="hidden">
                                                            <input id="hdCityCode"
                                                                   th:value="${model.data.returnedPurchase!=null ? model.data.returnedPurchase.cityCode:''}"
                                                                   type="hidden">
                                                            <input id="hdDistrictCode"
                                                                   th:value="${model.data.returnedPurchase!=null ? model.data.returnedPurchase.districtCode:''}"
                                                                   type="hidden">
                                                            <button class="btn-primary"
                                                                    onclick="orderHandler.modifyShipAddress()">修改退货地址
                                                            </button>
                                                        </td>
                                                    </tr>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script id="receivingInfo_modal" style="display: none" type="text/html">
    <div class="form-horizontal" style="width: 600px;">
        <div class="form-group">
            <label class="col-sm-2 control-label">收货人姓名:</label>
            <div class="col-sm-4">
                <div class="input-group">
                    <input name="receivingInfo_userName" id="receivingInfo_userName" value="" type="text"
                           class="form-control" placeholder="收货人姓名">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">收货人手机:</label>
            <div class="col-sm-4">
                <div class="input-group">
                    <input name="receivingInfo_telNumber" id="receivingInfo_telNumber" value="" type="text"
                           class="form-control" placeholder="收货人手机">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">城市:</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <select id="sltProvince" class="form-control input-s-sm">
                        <option>请选择</option>
                    </select>
                    <select id="sltCity" class="form-control input-s-sm">
                        <option>请选择</option>
                    </select>
                    <select id="sltDistrict" class="form-control input-s-sm">
                        <option>请选择</option>
                    </select>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">收货地址:</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input name="receivingInfo_address" style="width: 350px;" id="receivingInfo_address" value=""
                           type="text"
                           class="form-control" placeholder="收货地址">
                </div>
            </div>
        </div>
    </div>
</script>

<script src="../../resource/js/jquery.min2.2.4.js?v=2.1.4" th:src="@{/resource/js/jquery.min2.2.4.js?v=2.1.4}"></script>
<script src="../../resource/js/bootstrap.min.js?v=3.3.5" th:src="@{/resource/js/bootstrap.min.js?v=3.3.5}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-utils.js"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-utils.js(123123)}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-init.js"></script>

<script src="../../resource/hotui/js/content.min.js" th:src="@{/resource/hotui/js/content.min.js}"></script>
<script th:inline="javascript" type="text/javascript">
    const auditUri = /*[[@{/merchant/audit}]]*/  "";
</script>
<script>

    let handler = {
        modifyAudit(dataId) {
            hot.iframeModal(auditUri + "?id=" + dataId, "580px", "520px", "审核", {
                end: function (obj) {
                    window.location.reload();
                }
            });
        }
    }


    let auctionModal = $("#receivingInfo_modal").modal("修改退货信息", function () {
        let userName = $("#receivingInfo_userName").val();
        let telNumber = $("#receivingInfo_telNumber").val();
        let detailInfo = $("#receivingInfo_address").val();
        let provinceCode = $("#sltProvince").val();
        let cityCode = $("#sltCity").val();
        let districtCode = $("#sltDistrict").val();
        let provinceName = $("#sltProvince").find("option:selected").text();
        let cityName = $("#sltCity").find("option:selected").text();
        let countyName = $("#sltDistrict").find("option:selected").text();
        let merchantId = $("#merchantId").val();
        let requestData = {
            userName: userName,
            telNumber: telNumber,
            detailInfo: detailInfo,
            provinceCode: provinceCode,
            cityCode: cityCode,
            districtCode: districtCode,
            provinceName: provinceName,
            cityName: cityName,
            countyName: countyName,
            merchantId: merchantId
        };
        hot.ajax("/merchant/update/returnedPurchase", requestData, function (apiResult) {
            if (apiResult.resultCode === 2000) {
                hot.tip.success("设置成功", function () {
                    window.location.reload();
                });
            } else {
                hot.tip.error(apiResult.resultMsg);
            }
        }, function () {
        }, "post", 300);
    });

    let orderHandler = {
        init: function () {
            let that = this;
            $("#sltProvince").change(function () {
                that.initCity(this.value, "#sltCity");
            });

            $("#sltCity").change(function () {
                that.initCity(this.value, "#sltDistrict");
            })
        },

        initCity(pid, domId, callback) {
            let that = this;
            that.cities(pid, function (data) {
                let html = '<option value="0">请选择</option>';
                $.each(data, function (i, item) {
                    html += '<option value="' + item.id + '">' + item.name + '</option>';
                });
                $(domId).html(html);
                if (typeof callback == 'function') {
                    callback();
                }
            });
        },

        modifyShipAddress: function () {
            let that = this;
            auctionModal.show(function () {
                $("#receivingInfo_userName").val($("#hdShipUserName").val());
                $("#receivingInfo_telNumber").val($("#hdShipTelNumber").val());
                that.initCity(0, "#sltProvince");
                that.init();
            });
        },
        cities(pid = 0, callback) {
            hot.ajax("/order/cities", {
                pid: pid
            }, function (apiResult) {
                if (apiResult.resultCode === 2000) {
                    callback(apiResult.data);
                }
            }, function () {
            }, "get");
        },
    }


    function previewImage(obj) {
        let src = $(obj).attr('src');
        window.open(src, "_blank");
    }
</script>
</body>
</html>
